<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>跑马灯</title>
</head>
<body>

<div id="app">
    {{birthday}}
    <br>
    {{getBirth()}}
    {{getBirth()}}
    {{getBirth()}}
    <br>
    {{getBirth2}}
    {{getBirth2}}
    {{getBirth2}}

</div>


<script src="./node_modules/vue/dist/vue.js"></script>
<script>
    let mv = new Vue({
        el: "#app",
        data: {
            birthday: 1565588398790

        },
        methods: {
            getBirth() {
                console.log("getBirth");
                let date = new Date(this.birthday);
                return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDay()
            }
        },
        computed: {
            //带缓存 按属性
            getBirth2() {
                console.log("getBirth2");
                let date = new Date(this.birthday);
                return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDay()
            }

        }
    })


</script>


</body>
</html>